﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../lib/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>有机码管理</title>
</head>
<body>
    <div class="pd-20">
        <form id="itemEdit" name="itemEdit" method="post" action="../ashx/spui.ashx" class="form form-horizontal">
            <input type="hidden" class="actionValue" id="editAction" name="action" value="add" />
            <input type="hidden" id="id" name="id" />
            <input type="hidden" id="tablename" name="tablename" value="" />
            <input type="hidden" id="tablemidname" name="tablemidname" value="" />
            <input type="hidden" id="ftype" name="ftype" value="20171015" />
            <input type="hidden" id="fmaintype" name="fmaintype" value="20171015" />
            <input type="hidden" id="ftypename" name="ftypename" value="有机码" />
            <input type="hidden" id="dataneedtouser" name="dataneedtouser" value="1" />
            <!--是否要包含通用数据必归属处理-->
            <input type="hidden" id="ywcheckonly" name="ywcheckonly" value="ftype,fmaintype,ffv5,fdatabranchid#当前有机码已存在!" />
            <!--唯一性检查 所用字段要在表单中-->
            <div class="row cl">
                <label class="form-label col-2">基地：</label>
                <div class="formControls col-3">
                    <span class="select-box">
                        <select class="select" size="1" name="ffv1" id="ffv1" nullmsg="*" datatype="*1-26">
                        </select></span>
                    <input type="hidden" name="ffv2" id="ffv2" />
                </div>
                <div class="col-1"></div>
                <label class="form-label col-2">品种：</label>
                <div class="formControls col-3  layui-form">
                    <select name="ffv3" id='ffv3' lay-filter="ffv3" lay-verify="required" nullmsg="不能为空" datatype="*1-22" lay-search="">
                        <option value="">直接选择或搜索选择</option>
                    </select>
                    <input type="hidden" name="ffv4" id="ffv4" />
                </div>


                <div class="col-1"></div>
            </div>
            <div class="row cl">
                <input type="hidden" id="ffv7" name="ffv7" />
                <input type="hidden" id="codeends" name="codeends" value="error" />
                <input type="hidden" id="fnv1" name="fnv1" />
                <input type="hidden" id="fnv2" name="fnv2" />
                <input type="hidden" id="fnv3" name="fnv3" />
                <input type="hidden" id="fnv4" name="fnv4" />
                <input type="hidden" id="fnv5" name="fnv5" />
                <label class="form-label col-2">开始码：</label>
                <div class="formControls col-3">
                    <input type="text" class="input-text" name="ffv5" id="ffv5" placeholder="不能为空" nullmsg="*" datatype="*4-26" />
                </div>
                <div class="col-1"></div>
                <label class="form-label col-2">结束码：</label>
                <div class="formControls col-3">
                    <input type="text" class="input-text" name="ffv6" id="ffv6" placeholder="不能为空" nullmsg="*" datatype="*4-26" />
                </div>
                <div class="col-1"></div>
            </div>
            <div class="row cl">
                <label class="form-label col-2"><span class="c-red">*</span>说明：</label>
                <div class="formControls col-3">
                    <input type="text" class="input-text" name="ffv8" id="ffv8" placeholder="不能为空" />
                </div>
                <div class="col-1"></div>

            </div>
            <div class="row cl">
                <div class="col-6 col-offset-4">
                    <button class="btn btn-primary radius" type="submit" id="btsub1">提交</button>&nbsp;&nbsp;
				<button class="btn btn-secondary radius" type="button" id="btn_reset">重置</button>&nbsp;&nbsp;
				<button onclick="layer_close();" class="btn btn-default radius" type="button">返回</button>
                </div>
            </div>
        </form>
    </div>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layui/layui.js"></script>
    <script type="text/javascript" src="../lib/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="../lib/Validform/5.3.2/Validform.js"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_au.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        var uiform = null;
        //HcUiAuloadInfoAuto = true;//将自动加载，设置为false（禁用自动加载）
        var loadisOk = 1;
        hcui_ajaxasync = false;//禁用异步，先加载下拉信息
        //基地
        hcdoselbyPost("BranchID as id,BranchName as name", "mrbranch", "type='本部'", "", "", "id",
               function (data) { SetSelectWithArrayIdName("#ffv1", data); });
        hcdoselbyPost("id,fv1 as name", "yw_baseinfo", "type='1' and  maintype='1'", "", "", "id",
                function (data) {
                    SetSelectWithArrayIdName("#ffv3", data);
                   
                });
        hcui_ajaxasync = false;
        //加载处理
        function loadin() {
            //本页面 
            spsetBase("yw_baseinfo", "id", "yw_baseinfo as T", "*", "#tablelist", "baseinfo11", "品种出成率管理", "baseinfo11");
            layui.use(['form'], function () {
                uiform = layui.form();
                //基地
                if (uiform) uiform.render('');//这个好像不用再保留了            });
        }
        function loadback(data) {
           // uiform.render();//这个不能去掉,坑啊        }
        //重写  提交前数据处理
        function hcrBeforeSub() {
            $("#ffv2").val($('#ffv1 option:selected').text());
            $("#ffv4").val($('#ffv3 option:selected').text());
            //分析--开始码与结束码 长度一致
            if ($("#ffv5").val().length != $("#ffv6").val().length) {
                layer.msg('开始码与结束码,长度不一致', { icon: 2 });
                return false;
            }
            hcui_ajaxasync = false;
            hcapiget("../api/Hcrain/GetCodeNum", { "codeinfo": $("#ffv5").val() }, function (data) {
                $("#ffv7").val(data.codestring);
                $("#fnv1").val(data.codenum);
                $("#fnv2").val(data.codenuml);
                console.log(data)
            });
            hcapiget("../api/Hcrain/GetCodeNum", { "codeinfo": $("#ffv6").val() }, function (data) {
                $("#codeends").val(data.codestring);
                $("#fnv3").val(data.codenum);
                $("#fnv4").val(data.codenuml);
                console.log(data)
            });

            //分析--开始码与结束码 非数值部分一致
            if ($("#ffv7").val() != $("#codeends").val()) {
                layer.msg('开始码与结束码,不是同一个号段噢', { icon: 2 });
                return false;
            }
            console.log($("#fnv2").val());
            //分析--开始码与结束码 的数值结束的要是数值
            if (($("#fnv2").val() * 1) <= 0) {
                layer.msg('号段应该以数值结尾', { icon: 2 });
                return false;
            }
            console.log($("#fnv3").val() + "------" + $("#fnv1").val());
            //分析--开始码与结束码 的数值结束的要》=开始的
            if (($("#fnv3").val() * 1) < ($("#fnv1").val() * 1)) {
                layer.msg('结束码应该大于等于开始码', { icon: 2 });
                return false;
            }

            $("#fnv5").val(($("#fnv3").val() * 1) - ($("#fnv1").val() * 1) + 1);
            console.log("id:" + aumid);
            var addwhere = " and 1=1 ";
            if (aumid != "") {
                addwhere = " and id != " + aumid;
            }
            //本身验证成功
            //开始码及结束码都不在库中
            hcui_ajaxasync = false;
            var okornoe = false;
            hcdoselbyPost("id,fv5,fv6", "yw_baseinfo", "type=20171015 and  fv7='" + $("#ffv7").val() + "' and nv2 =" + $("#fnv2").val() + " and ((nv1<=" + $("#fnv1").val() + " and nv3>=" + $("#fnv1").val() + ") or  (nv1<=" + $("#fnv3").val() + " and nv3>=" + $("#fnv3").val() + ") )  " + addwhere,
                "", "", "id",
            function (data) {
                if (data.length > 0) {
                    layer.msg('输入的开始码与别的记录重复而冲突，如：' + data[0].fv5, { icon: 2 });
                    okornoe = false;
                    return false;
                }
                else { okornoe = true; }
            });
            return okornoe;
        }
    </script>
</body>
</html>
